<template>
	<view class="wrap">
		<ErrDialog v-if="errDialogOpen" ref="errDialog" :dialogData="dialogData" @retryFunciton="retryFunciton">
		</ErrDialog>
		<!-- <PdaScan></PdaScan> -->
		<!-- :is-scroll="true" -->
		<!-- <u-tabs :list="list" :current="current" @change="change"></u-tabs> -->
		<!-- 主要展示 -->
		<view  >
			<view class="example-body">
				<u-form-item label="货位" label-width="170" right-icon="">
					<u-input
					 @click="changeScanInput('searchForm.location')"
					 v-model="searchForm.location" placeholder="请输入货位或扫码" style="width: 80%;" />
				</u-form-item>
			</view>
			<!-- <view class="search">
				<u-search input-align="center" height="70" v-model="goods" placeholder="请输入商品信息"
					@custom='searchMx'></u-search>
			</view> -->
			<u-empty v-if="!oneMx" text="无明细数据,请尝试不同的搜索条件" mode="page"></u-empty>

			<view v-if="oneMx" class="example-body" style="padding-bottom: 140rpx;">
			
				<view>
					<u-form>
						<!-- {{oneMx}} -->
						<u-form-item label="货主信息" label-width="170" right-icon="">
							<u-input v-model="oneMx.YEZ_NAME" @blur="blurFunction" :disabled="disableTrue"
								placeholder="货主信息" />
						</u-form-item>
						<!-- <u-form-item label="上游编码" label-width="170" right-icon="">
								<u-input v-model="oneMx.INPAGENO_YW" @blur="blurFunction" :disabled="disableTrue"
									placeholder="上游编码" />
							</u-form-item> -->
						<u-form-item label="商品编码" label-width="170" right-icon="">
							<u-input v-model="oneMx.GDSEQ" @blur="blurFunction" :disabled="disableTrue"
								placeholder="商品编码" />
						</u-form-item>
						<u-form-item label="商品名称" label-width="170" right-icon="">
							<u-input v-model="oneMx.GDNAME" :title="oneMx.GDNAME" @blur="blurFunction"
								:disabled="disableTrue" placeholder="商品名称" />
						</u-form-item>
						<u-form-item label="商品规格" label-width="170" right-icon="">
							<u-input v-model="oneMx.GDSPEC" :title="oneMx.GDSPEC" @blur="blurFunction"
								:disabled="disableTrue" placeholder="商品规格" />
						</u-form-item>
						<!-- @blur="blurFunction" -->
						<u-form-item label="库存数量" label-width="170" right-icon="">
							<!-- <u-input v-model="oneMx.SHIS_AMOUNT" style="padding-left: 30px;" :title="oneMx.SHIS_AMOUNT"
									 :disabled="disableTrue" placeholder="已收" />
								<view style="color: #999999;display: inline;">/</view> -->
							<u-input v-model="oneMx.AMOUNT" :title="oneMx.AMOUNT" @blur="blurFunction"
								:disabled="disableTrue" placeholder="库存数量" style="padding-left: 30px;color:orange;" />
						</u-form-item>
						<u-form-item label="入库预占" label-width="170" right-icon="">
							<u-input v-model="oneMx.AMOUNT_ZCYR" :title="oneMx.GDSPEC" @blur="blurFunction"
								:disabled="disableTrue" placeholder="入库预占" />
							<view style="color: #999999;display: inline;">/</view>
			
							<u-input v-model="oneMx.AMOUNT_PK" :title="oneMx.GDSPEC" @blur="blurFunction"
								:disabled="disableTrue" placeholder="预占" />
						</u-form-item>
			
			
						<!-- <u-divider color="#fa3534" half-width="400"></u-divider> -->
						<u-form-item label="批号" label-width="170" right-icon="">
							<u-input v-model="oneMx.BATCHNO" :disabled="disableTrue" @blur="blurFunction"
								placeholder="请输入批号" />
						</u-form-item>
						<u-form-item label="生产日期" label-width="170" right-icon="arrow-right">
							<!-- <u-calendar v-model="calendaShow"  mode="date" @change="changeProductDate"></u-calendar> -->
							<u-input v-model="oneMx.PRODUCTDATE" :disabled="disableTrue" @click="calendaShow = true"
								placeholder="请输入生产日期" />
						</u-form-item>
						<u-form-item label="有效期" label-width="170" right-icon="arrow-right">
							<!-- <u-calendar v-model="calendaEffdateShow" mode="date" max-date="9999-01-01"
									@change="changeEFFDATE"></u-calendar> -->
							<u-input v-model="oneMx.EFFDATE" :disabled="disableTrue" @click="calendaEffdateShow = true"
								placeholder="请输入有效期" />
						</u-form-item>
			
						<u-form-item label="货位" label-width="170" right-icon="">
							<u-input v-model="oneMx.LOCATION" :disabled="disableTrue" @blur="blurFunction"
								placeholder="请输入货位" />
							<!-- <u-button @click="scan1('LOCATIONZD')">扫码</u-button> -->
			
						</u-form-item>
			
						<!-- <u-form-item label="托盘号" label-width="170" right-icon="">
								<u-input v-model="oneMx.TPBAR" :disabled="disableTrue" @blur="blurFunction"
									placeholder="请输入托盘号" />
							</u-form-item> -->
			
						<!-- 	<u-form-item label="状态" label-width="170" right-icon="">
								<u-input v-model="oneMx.GDSTATUS" :disabled="disableTrue" @blur="blurFunction"
									placeholder="请输入状态" />
							</u-form-item> -->
			
						<!-- <u-form-item label="目标货位" label-width="170" right-icon="">
							<u-input
							@click="changeScanInput('totalLocation')"
							 :focus="focusTotalLocation"
							 v-model="totalLocation" @blur="blurFunction" placeholder="请输入目标货位" />
							<u-button shape="circle" size="mini" @click="scan1('totalLocation')">扫描</u-button>
						</u-form-item>
						<u-form-item label="转移数量" label-width="170" right-icon="">
							<u-input
							@click="changeScanInput('zyAmount')"
							v-model="zyAmount" type="number" @blur="blurFunction" placeholder="请输入转移数量" />
						</u-form-item> -->
					</u-form>
					<view v-show="showHeight" style="margin: 360rpx;"></view>
					<!-- <u-gap height="20" bg-color="#f5f5f5"></u-gap> -->
			
			
				</view>
			
			</view>
			<u-row gutter="32" class="more-bottom-box" justify="center">
				<!-- <u-col span="10">
					<view style="text-align: center;margin-top: 35rpx;"> -->
						<!-- <u-button class="tow-button" type="error" shape="circle"
							:disabled="!oneMx.GDSEQ"
							@click="removeLocation()"
							>报废</u-button> -->
							
							<!-- <u-button class="tow-button"
							 :disabled="!oneMx.GDSEQ"
							 type="" shape="circle"
								@click="submitRelocation('location')"
								>提交</u-button>
					</view>
				</u-col> -->  
				<u-col span="10">
					<view><u-button class="more-button"
							 :disabled="!oneMx.GDSEQ"
							 type="" shape="circle"
								@click="submitError('location')"
								>提交</u-button>
					</view>
				</u-col>
				<u-col span="10">
					<view><u-button
					 class="more-button"
					 type="primary"
					  shape="circle" @click="searchMx()">查询</u-button>
					</view>
				</u-col>

			</u-row>
		</view>
	</view>
</template>
<script>
	import ErrDialog from '@/components/err-dialog.vue'
	export default {
		components: {
			ErrDialog
		},

		data() {
			return {
				// 给一个初始值
				scanInput: '',
				scanResult: '',
				showHeight: false,
				searchForm:{
					yez_id:'',
					//BC01-010272
					//1排4列1层
					location:'',
					goodsMessage:'',
				},
				// 业主资料集合
				yzzlList: [],
				errDialogOpen: false,
				// 提示信息
				dialogData: {
					title: '出库',
					msgType: '',
					errContent: '',
					confirmText: '',
					functionName: '',
					cancelText:'',
					closeFunction:'',
				},
				//是否为正常物料
				ISZCGD:'',
				keywords: '',
				form: {
					huoz_id: '',
					tpbar: '',
					itm: '',
					rwid: '',
				},
				border: true,
				show: false,
				//库房展示
				kufShow: false,

				// 工作台下拉展示
				gzzShow: false,
				// 当前工作台中文
				gztNowLabel: '',
				GZTID: '',
				// 托盘的商品明细
				tpbarGoodsList: [],
				//选中的明细
				SEQNO: '',
				//当前选中的托盘号
				tpbar: '',
				kuf: '',
				// 商品相关条件
				goods: '',
				gztList: [],
				kufList: [],
				//日历选择显示
				calendaShow: false,
				//有效期日历显示
				calendaEffdateShow: false,
				list: [{
					name: '明细筛选'
				}, {
					name: '明细总览',
				}],

				m2mSimflowList: [],
				m2mOrderFlowList: [],
				current: 0,
				result1: '',
				status: 'nomore',
				iconType: 'circle',
				isDot: false,
				loadText: {
					loadmore: '点击加载更多',
					loading: '正在加载...',
					nomore: '没有更多了'
				},
				// 搜索栏的托盘号
				tpbar: '',
				nvueWidth: 730,
				only_one: [{
					text: '选择此项',
					value: 0
				}],
				// 基础表单数据
				baseFormData: {
					name: '',
					age: '',
					introduction: '',
					sex: 2,
					hobby: [5],
					datetimesingle: 1627529992399
				},
				hzData: {
					INPAGENO: "",
					INPAGENOYW: "",
					STORAGEID: "",
					INTYPE: "",
					INDATE: ""
				},
				refreshInHead: true,
				refreshMxMsg: true,
				mxList: [

				],

				oneMx: '',
				disableTrue: true,
				// 入库点
				landpoint: '',
				sjAmouont: '1',
				sjLocation: '',
			}
		},
		onUnload() {
			// 移除监听事件
			uni.$off('scancodedate')
		},
		onLoad() {
			//激光扫描监听事件
			var _this = this
			uni.$on("scancodedate", async (res) => {
				console.log("货位盘查页面监听到的async:" + res); //我是全局事件订阅的调用方法
				_this.scanResult = JSON.stringify(res);
				setTimeout(() => {
					_this.changeScanValue()
				}, 20);
			})

		},
		// onLoad(option) {
		// 	if (option) {
		// 		if (option.item) {
		// 			let item = JSON.parse(option.item)
		// 			this.hzData = item
		// 			console.log('收到的:' + JSON.stringify(item))
		// 			console.log('收到的:' + item.INPAGENO)
		// 			this.tpbar = item.INPAGENO;
		// 			this.getInListOneInfo()
		// 		}
		// 	}
		// },

		created() {
			// this.getGzt()
			// this.getKuf()
			// this.getYzzl()
			// this.init()
			// this.searchMx()
		},
		// 数据变化适用
		onShow() {
			this.myShow()

		},
		onBackPress() {
			console.log("点击了返回")
			uni.switchTab({
				url: "/pages/sys/workbench/wms-work"
			})
			return true
		},
		methods: {
			// 判定点击的哪个输入框
						changeScanInput(inputItem) {
							console.log(inputItem)
							this.scanInput = inputItem
							//this.$u.toast(JSON.stringify(inputItem))
						},
						// 扫描后执行的方法,判断输入框并绑定值,可以自行跳转,或者扫描完执行某方法,
						changeScanValue() {
							let scanInput = this.scanInput
							let result = JSON.parse(this.scanResult)
							if ("searchForm.location" === scanInput) {
								console.log("this.searchForm.location")
								this.searchForm.location = result
							} else if("searchForm.goodsMessage" === scanInput){
								this.searchForm.goodsMessage = result
							} else if("form.landpoint" === scanInput){
								this.form.landpoint = result
							} else if("form.tpbar" === scanInput){
								this.form.tpbar = result
							} else if("form.batchno" === scanInput){
								this.form.batchno = result
							} else if("form.amount" === scanInput){
								this.form.amount = result
							} else {
								// this.$u.toast('没有预先适配:' + scanInput)
								console.log('没有预先适配:' + scanInput)
							}
						},
			// 下拉内容是否展开
			showSelector(res) {
				console.log(res)
				this.showHeight = res
			},
			changeYezId(e) {
				this.searchForm.yez_id = e
				uni.setStorageSync("inventory-location-yez_id",e)
				console.log("选择的业主id:"+uni.getStorageSync("inventory-location-yez_id"))
			},
			getYzzl() {

				const USER_ID = uni.getStorageSync('USER_ID')

				let param = USER_ID;
				console.log("iv_parm:" + param)
				this.$u.api.general({
						iv_code: "GETYZZL",
						iv_parm: param
					})
					.then(res => {

						console.log("返回的res:" + JSON.stringify(res))
						let data = res.data
						console.log("getYzzl返回的data:" + JSON.stringify(data))

						if (res.success) {
							// this.yzzlList = data
							//补充text
							this.yzzlList = data.map(v => {
								this.$set(v, 'text', v.YEZ_NAME + "(" +
									v.YEZ_ID + ")")
								this.$set(v, 'value', v.YEZ_ID)
								return v
							})
							// this.kufList = data.map(v => {
							// 	this.$set(v, 'text', v.KUF_NO)
							// 	this.$set(v, 'value', v.KUF_NO)
							// 	return v
							// })
							// 增加一个全部货主的选项
							this.yzzlList.push(
							{"YEZ_SIMPLENAME":"所有货主","YEZ_NAME":"所有货主","YEZ_NO":"","YEZ_ID":"","text":"所有货主"}
							)
						} else {
							this.$u.toast(res.msg);
						}
					});
			},
			// 选中某个单选框时，由radio时触发
			radioChange(e) {
				console.log(e);
			},
			// 选中任一radio时，由radio-group触发
			radioGroupChange(e) {
				console.log(e);
			},
			navTo(url) {
				// uni.navigateTo({
				// 	url: url
				// });
				// uni.switchTab({
				// 	url: url
				// });
				uni.switchTab({
					url: url,
					success: function(e) {
						var page = getCurrentPages().pop(); // 返回页面数组的最后一个页面数据
						if (page == undefined || page == null)
							return; //如果最后一个页面为undefined或null，即当前就在首页 return出去，不调用onLoad
						page.onLoad();
					}
				});


			},
			searchMx() {
				// this.getInListOneInfo()
				// this.getOutTpbarList()
				this.getLocationMxList()
			},
			removeLocation(){
				this.dialogData = {
					title: '报废',
					msgType: 'info',
					errContent: '报废提交后无法恢复',
					confirmText: '报废提交',
					// 如果选右边的执行的返回方法
					functionName: 'submitRelocationRemove',
					cancelText: '取消',
					closeFunction: '',
				}
				this.errDialogShow()
			},
			
			submitError(paramReturn) {
			
			// 明细结果
			//{
//   "LOCATION": "1排4列1层",
//   "LOCATIONID": "SXK00003704",
//   "NUM_DABZ": "1",
//   "AMOUNT_BHYR": "0",
//   "EFFDATE": "2999-12-31",
//   "GDSEQ": "TP000001",
//   "PRODUCTDATE": "2023-01-01",
//   "ITEMID_UPPER": "0",
//   "KEEPACCOUNT": "*",
//   "CONTAINSNUMBER": "*",
//   "GDSPEC": "托盘",
//   "AMOUNT": "1",
//   "YEZ_NAME": "盐城锦鲤",
//   "AMOUNT_ZCYC": "0",
//   "UNIT_DABZ": "盒",
//   "BATCHNO": "KTP",
//   "GDNAME": "托盘TP000001",
//   "AMOUNT_ZCYR": "0",
//   "AMOUNT_PK": "0",
//   "EFFDATE_PRINT": "31-12月-99",
//   "INDATE": "20230625",
//   "AMOUNT_SYKY": "1",
//   "TPBAR": "19",
//   "YEW_STATE": "*",
//   "GOODSID": "GDID2021000000000001",
//   "GDSTATUS": "1",
//   "AMOUNT_PY": "0",
//   "AMOUNT_BHYC": "0",
//   "STORAGEID": "1010",
//   "YEZ_ID": "8888",
//   "ITEMID": "13",
//   "UNIQUECODE": "0",
//   "AMOUNT_SD": "0",
//   "PRODUCTDATE_PRINT": "01-1月 -23"
// }
				// 1、IV\_USER\_ID 用户id
				// 2、IV\_STORAGEID 仓库id
				// 3、IV_GZTID  工作台传空
				// 4、IV_BILLTYPE  单据类型 传Y15
				// 5、IV\_YEZ\_ID 业主id
				// 6、IV\_GOODSID 商品id
				// 7、IV\_ITEMID 批次id
				// 8、IV\_BATCHNO 批号
				// 9、IV\_UNIQUECODE 唯一码
				// 10、IV\_GOODSTATUS 库存状态
				// 11、IV_YEW_STATE 业务状态
				// 12、IV_KEEPACCOUNT
				// 13、IV_CONTAINSNUMBER
				// 14、IV_TPBAR  托盘号
				// 15、IV\_LOCATIONID 移出货位
				// 16、IV\_LOCATIONID\_T 移入货位
				// 17、IV\_AMOUNT 数量
				// 18、IV_BILLNOYW 业务单号，传空
				// 19、IV_CHUL_TYPE 处理类型传1
			
				console.log("oneMx=>" + JSON.stringify(this.oneMx))
				const USER_ID = uni.getStorageSync('USER_ID')
				const STORAGEID = uni.getStorageSync('STORAGE_ID')
				const GZTID = uni.getStorageSync('GZTID')
				const BILLTYPE = 'Y15'
				
				const YEZ_ID = this.oneMx.YEZ_ID ? this.oneMx.YEZ_ID : '%'
				const GOODSID = this.oneMx.GOODSID ? this.oneMx.GOODSID : "%"
				const ITEMID = this.oneMx.ITEMID ? this.oneMx.ITEMID : "%"
			
				const BATCHNO = this.oneMx.BATCHNO ? this.oneMx.BATCHNO : "%"
				const UNIQUECODE = this.oneMx.UNIQUECODE ? this.oneMx.UNIQUECODE : "%"
				const GOODSTATUS = this.oneMx.GDSTATUS ? this.oneMx.GDSTATUS : '1'
				// 11
				const YEW_STATE = this.oneMx.YEW_STATE ? this.oneMx.YEW_STATE : "%"
				const KEEPACCOUNT = this.oneMx.KEEPACCOUNT ? this.oneMx.KEEPACCOUNT : "%" 
				const CONTAINSNUMBER = this.oneMx.CONTAINSNUMBER ? this.oneMx.CONTAINSNUMBER : "%" 
				const TPBAR = this.oneMx.TPBAR ? this.oneMx.TPBAR : '%'
				console.log(JSON.stringify(this.oneMx))
				// debugger
				const LOCATIONID = this.oneMx.LOCATIONID ? this.oneMx.LOCATIONID : "%"
				let LOCATIONID_T =""
				let AMOUNT =this.oneMx.AMOUNT ? this.oneMx.AMOUNT :'0'
				// if(paramReturn==='remove'){
				// 	LOCATIONID_T =  ""
				// 	AMOUNT = this.oneMx.AMOUNT ? this.oneMx.AMOUNT :'0'
				// }else{
					 // LOCATIONID_T = this.searchForm.location ? this.searchForm.location : "%"
					 // AMOUNT = this.oneMx.AMOUNT ? this.oneMx.AMOUNT :'0'
				// }
				const BILLNOYW=""
				const CHUL_TYPE="1"
				
			// debugger
				// if (this.zyAmount < 1) {
				// 	this.$u.toast('转移数量不可以小于1')
				// 	return
				// }
			
				let param = USER_ID + "," +
					STORAGEID + "," +
					GZTID + "," +
					BILLTYPE + "," +
					YEZ_ID + "," +
					GOODSID + "," +
					ITEMID + "," +
			
					BATCHNO + "," +
					UNIQUECODE + "," +
					GOODSTATUS + "," +
					YEW_STATE + "," +
					KEEPACCOUNT + "," +
					CONTAINSNUMBER + "," +
					TPBAR + "," +
			
					LOCATIONID + "," +
					LOCATIONID_T + "," +
					AMOUNT+ "," +
					BILLNOYW
					// + "," +
					// CHUL_TYPE
					;
			
				console.log("iv_parm:" + param + ";")
				let that = this
				this.$u.api.prcutlexecvar({
						iv_code: "PDATRANSFERSAVE",
						iv_parm: param,
						ov_var1: '2',
						ov_var2: '2',
						ov_var3: '2',
						ov_var4: '2',
						ov_var5: '2',
					})
					.then(res => {
						console.log("返回的res:" + JSON.stringify(res))
						if (res.success) {
							that.$u.toast(res.msg);
							let data = res.data
							// console.log("返回的data:" + JSON.stringify(data))
							console.log("返回的res.msg:" + res.msg)
							this.submitSuccess()
							if (paramReturn == "returnSearch") {
								this.current = 0
							}
						} else {
							this.dialogData = {
								title: '提交',
								msgType: 'warn',
								errContent: res.msg,
								confirmText: '重新提交',
								// 如果选右边的执行的返回方法
								functionName: 'submitError',
								cancelText: '关闭',
								closeFunction: '',
							}
							this.errDialogShow()
						}
			
					});
			},
			
			submitRelocation(paramReturn) {
			
			
				// 1、IV\_USER\_ID 用户id
				// 2、IV\_STORAGEID 仓库id
				// 3、IV\_YEZ\_ID 业主id
				// 4、IV\_GOODSID 商品id
				// 5、IV\_ITEMID 批次id
				// 6、IV\_BATCHNO 批号
				// 7、IV\_UNIQUECODE 唯一码
				// 8、IV\_GOODSTATUS 库存状态
				// 9、IV\_YEWZT 业务状态
				// 10、IV_TPBAR  托盘号
				// 11、IV\_LOCATIONID 移出货位
				// 12、IV\_LOCATIONID\_T 移入货位
				// 13、IV\_AMOUNT 数量
			
			
			
				console.log("oneMx=>" + JSON.stringify(this.oneMx))
				const USER_ID = uni.getStorageSync('USER_ID')
				const STORAGEID = uni.getStorageSync('STORAGEID')
				const YEZ_ID = this.oneMx.YEZ_ID ? this.oneMx.YEZ_ID : '%'
				const GOODSID = this.oneMx.GOODSID ? this.oneMx.GOODSID : "%"
				const ITEMID = this.oneMx.ITEMID ? this.oneMx.ITEMID : "%"
			
				const BATCHNO = this.oneMx.BATCHNO ? this.oneMx.BATCHNO : "%"
				const UNIQUECODE = this.oneMx.UNIQUECODE ? this.oneMx.UNIQUECODE : "%"
				const GOODSTATUS = this.oneMx.GOODSTATUS ? this.oneMx.GOODSTATUS : '%'
				const YEW_STATE = this.oneMx.YEW_STATE ? this.oneMx.YEW_STATE : "%"
				const TPBAR = this.oneMx.TPBAR ? this.oneMx.TPBAR : '%'
				console.log(JSON.stringify(this.oneMx))
				// debugger
				const LOCATIONID = this.oneMx.LOCATIONID ? this.oneMx.LOCATIONID : "%"
				let LOCATIONID_T ="%"
				let AMOUNT ="0"
				if(paramReturn==='remove'){
					LOCATIONID_T =  ""
					AMOUNT = this.oneMx.AMOUNT ? this.oneMx.AMOUNT :'0'
				}else{
					 LOCATIONID_T = this.searchForm.location ? this.searchForm.location : "%"
					 AMOUNT = this.oneMx.AMOUNT ? this.oneMx.AMOUNT :'0'
				}
				
			// debugger
				// if (this.zyAmount < 1) {
				// 	this.$u.toast('转移数量不可以小于1')
				// 	return
				// }
			
				let param = USER_ID + "," +
					STORAGEID + "," +
					YEZ_ID + "," +
					GOODSID + "," +
					ITEMID + "," +
			
					BATCHNO + "," +
					UNIQUECODE + "," +
					GOODSTATUS + "," +
					YEW_STATE + "," +
			
					TPBAR + "," +
					LOCATIONID + "," +
					LOCATIONID_T + "," +
					AMOUNT;
			
				console.log("iv_parm:" + param + ";")
				let that = this
				this.$u.api.prcutlexecvar({
						iv_code: "PDATRANSFERSAVE",
						iv_parm: param,
						ov_var1: '2',
						ov_var2: '2',
						ov_var3: '2',
						ov_var4: '2',
						ov_var5: '2',
					})
					.then(res => {
						console.log("返回的res:" + JSON.stringify(res))
						if (res.success) {
							that.$u.toast(res.msg);
							let data = res.data
							// console.log("返回的data:" + JSON.stringify(data))
							console.log("返回的res.msg:" + res.msg)
							this.submitSuccess()
							if (paramReturn == "returnSearch") {
								this.current = 0
							}
						} else {
							this.dialogData = {
								title: '提交',
								msgType: 'error',
								errContent: res.msg,
								confirmText: '重新提交',
								// 如果选右边的执行的返回方法
								functionName: 'submitRelocation',
								cancelText: '关闭',
								closeFunction: '',
							}
							this.errDialogShow()
						}
			
					});
			},
			overStyle(over) {
				if (over) {
					return "text-align: right;color: #58ca93;";
				} else {
					return "text-align: right;color: #f28c03;";
				}
			},
			init() {
				this.GZTID = uni.getStorageSync('IN_GZTID')
				this.kuf = uni.getStorageSync('kuf')
			},
			goTo(item, index) {
				if (item.over) {
					this.$u.toast('已完成入库,请选择其他入库单明细')
					return
				} else {
					let item = this.mxList[index]
					// 如果托盘号填写了 ,则不用改,如果为空,则把选中的托盘号放进去
					if (this.tpbar.length > 0) {

					} else {
						// 通过点击明细,输入了入库单号,以及 预览的一些数据
						// this.tpbar = item.TPBAR
						// this.getInListBytpbar()
						this.tpbar = item.TPBAR
					}
					this.getOutInfoByTpbar()
					console.log('item:' + JSON.stringify(item))
					item.index = Number(index + 1)
					// this.oneMx = item
					// tabs转换到第一个
					this.change(1)
				}

				// let id = item.INPAGENO
				// uni.navigateTo({
				// 	url: 'index?item=' + JSON.stringify(item)
				// });
			},
			// 根据托盘号,获取出库商品明细集合   返回集合后,获取到物料号后,询问第一个物料
			getOutInfoByTpbar() {
				//1、IV\_STAFF 用户id
				// 2、IV\_GZTID 工作站
				// 3、IV\_BARCODE 托盘号，单号

				const USER_ID = uni.getStorageSync('USER_ID')
				const GZTID = this.GZTID ? this.GZTID : "%"
				const tpbar = this.tpbar ? this.tpbar : "%"

				let param = USER_ID + "," + GZTID + "," + tpbar;
				console.log("iv_parm:" + param)
				this.$u.api.general({
						iv_code: "PDAOUTTPBARMX",
						iv_parm: param
					})
					.then(res => {
						 console.log("返回的res:" + JSON.stringify(res))
						if (res.success) {
							let data = res.data
							console.log("返回的data:" + JSON.stringify(data))
							this.tpbarGoodsList = data
							// 默认选中第一个
							this.SEQNO = data[0].SEQNO
							this.oneMx = data[0]
							//是否新批次出库第一托
							// this.isFirshOut()
							// this.hzData = data[0]
							// if (this.list.length < 1) {
							// 	this.$u.toast("没有查到数据");
							// }
						} else {
							this.$u.toast(res.msg);
						}
					});
			},
			// 是否新批次出库第一托?
			isFirshOut() {
				// 1、IV\_STAFF 用户id
				// 2、IV\_GOODSID 商品id
				// 3、IV\_ITEMID 批次
				// 4、IV\_BATCHNO 批号
				// 5、IV\_OUT\_LX 出库场景类型
				// 6、IV\_CKJH 出库下发：1，拣货2
				const USER_ID = uni.getStorageSync('USER_ID')

				const GOODSID = this.oneMx.GOODSID ? this.oneMx.GOODSID : "%"
				const ITEMID = this.oneMx.ITEMID ? this.oneMx.ITEMID : "%"
				const BATCHNO = this.oneMx.BATCHNO ? this.oneMx.BATCHNO : "%"
				const OUT_LX = this.oneMx.OUTTYPE ? this.oneMx.OUTTYPE : "%"
				const CKJH = 2
				let param = USER_ID + "," + GOODSID + "," + ITEMID + "," +
					BATCHNO + "," + OUT_LX + "," + CKJH;
				console.log("iv_parm:" + param)
				this.$u.api.general({
						iv_code: "PDAGETFIRSTOUTFLG",
						iv_parm: param
					})
					.then(res => {
						 console.log("返回的res:" + JSON.stringify(res))
						if (res.success) {
							let data = res.data
							console.log("返回的data:" + JSON.stringify(data))
							// this.hzData = data[0]
							// if (this.list.length < 1) {
							// 	this.$u.toast("没有查到数据");
							// }

							// 如果是第一次出库,进行提示
							if(data.ISFIRSTOUT == 'Y'){
								this.dialogData={
									title:'出库检测(第一托?)',
									msgType: 'warn',
									errContent: '本明细是新批次出库第一托',
									confirmText:'继续进行出库(判断是否为正常物料)',
									// 如果选右边的执行的返回方法
									functionName:'isNarmalGoods',
									cancelText:'关闭',
								}
								this.errDialogShow()
								this.ISZCGD = data.ISZCGD
								// if(data.ISZCGD=='Y'){
								// 	this.ISZCGD = 'Y'
								// }
							}else{
								this.submitOut()
							}

						} else {
							this.$u.toast(res.msg);
						}
					});
			},
			retryFunciton(e){
				console.log("子组件返回的e:"+e)
				if(e=="isNarmalGoods"){
					this.isNarmalGoods()
				}else if(e=='getLocationMxList'){
					this.getLocationMxList()
				}else if(e=='submitRelocation'){
					this.submitRelocation()
				}else if(e=='submitRelocationRemove'){
					this.submitRelocation('remove')
				}else if(e=='submitError'){
					this.submitError()
				}
				
			},
			// 是否是
			isNarmalGoods(){
				if(this.ISZCGD == 'Y'){
					// (对应PDA弹窗提醒)
					this.dialogData={
						title:'出库检测(正常物料?)',
						msgType: 'warn',
						errContent: '本明细是正常物料',
						confirmText:'我知道了',
						// 如果选右边的执行的返回方法
						functionName:'submitOut',
						cancelText:'关闭',
					}
					this.errDialogShow()
				}else if(this.ISZCGD == 'N'){
					// 对应pda弹窗选择确认
					this.dialogData={
						title:'出库检测(正常物料?)',
						msgType: 'error',
						errContent: '本明细不是正常物料',
						confirmText:'同意此物料不是正常物料',
						// 如果选右边的执行的返回方法
						functionName:'submitOut',
						cancelText:'拒绝',
						closeFunction:'noNormalGoods',

					}
					this.errDialogShow()
				}else{
					this.$u.toast('ISZCGD未知,严重错误,请排查isFirshOut()返回值')
				}
			},
			noNormalGoods(){
				this.$u.toast('点击了否,不同意')
			},
			// // 是正常物料的弹窗提示(权限控制,指定账号弹窗)
			// isToast(){

			// },
			errDialogShow() {
					console.log("刷新显示提示框")
					//刷新显示
					let that = this;
					that.errDialogOpen = false;
					that.$nextTick(() => {
						that.errDialogOpen = true;
					})

				},
			getInListBytpbar() {
				const STORAGE_ID = uni.getStorageSync('STORAGE_ID')
				const huoz_id = "%"
				const USER_ID = uni.getStorageSync('USER_ID')
				const inbillNumber = this.tpbar ? this.tpbar : "%"

				const unit = "%"
				const goodsId = "%"
				const palletNumber = "%"
				let param = STORAGE_ID + "," + huoz_id + "," + USER_ID + "," +
					inbillNumber + "," + unit + "," + goodsId + "," + palletNumber;
				console.log("iv_parm:" + param)
				this.$u.api.general({
						iv_code: "PDAINBILLINPAGENO",
						iv_parm: param
					})
					.then(res => {
						 console.log("返回的res:" + JSON.stringify(res))
						if (res.success) {
							let data = res.data
							console.log("返回的data:" + JSON.stringify(data))
							this.hzData = data[0]
							// if (this.list.length < 1) {
							// 	this.$u.toast("没有查到数据");
							// }
						} else {
							this.$u.toast(res.msg);
						}
					});
			},
			//重新加载子组件
			myShow() {

				console.log("this.hzData==>" + JSON.stringify(this.hzData))
				//刷新显示
				let that = this;
				that.refreshInHead = false;
				that.$nextTick(() => {
					that.refreshInHead = true;
				})

			},
			myMxShow() {
				//刷新显示
				let that = this;
				that.refreshMxMsg = false;
				that.$nextTick(() => {
					that.refreshMxMsg = true;
				})

			},

			scan1(param) {
				console.log("扫描")
				// #ifdef H5
				this.$u.toast('H5页面不支持扫码,请用安卓等移动设备重试')
				// #endif
				let that = this;
				// 允许从相机和相册扫码
				uni.scanCode({
					success: function(res) {
						if (param == "location") {
							that.searchForm.location = res.result;
						} else if (param == "LOCATIONZD") {
							that.sjLocation = res.result
						}

					}
				});
			},
			change(index) {
				console.log(this.current)
				this.current = index;
			},
			submit(index) {
				if (this.tpbar) {
					this.$u.toast('调用下架接口')
				} else {
					this.$u.toast('请补充入库单号的数据')
				}
			},
			submitOutBefore(){
				//是否新批次出库第一托
				this.isFirshOut()
			},
			submitOut(paramReturn) {
				// 1、IV\_STAFF 用户
				// 2、IV\_GZTID 工作站
				// 3、IV\_TPBAR 托盘
				// 4、IV\_SEQNO 序列号
				// 5、IN\_AMOUNT 数量

				console.log("oneMx=>" + JSON.stringify(this.oneMx))
				const USER_ID = uni.getStorageSync('USER_ID')
				const GZTID = this.GZTID ? this.GZTID : "%"
				const TPBAR = this.oneMx.TPBAR ? this.oneMx.TPBAR : "%"
				const SEQ_NO = this.SEQNO ? this.SEQNO : "%"
				const AMOUNT = this.oneMx.AMOUNT ? this.oneMx.AMOUNT : "0"


				let param = USER_ID + "," +
					GZTID + "," +
					TPBAR + "," +
					SEQ_NO + "," +
					AMOUNT;


				console.log("的iv_parm:" + param + ";")
				let that = this
				this.$u.api.prcutlexecvar({
						iv_code: "PDAOUTTPBARQR",
						iv_parm: param,
						ov_var1: '2',
						ov_var2: '2',
						ov_var3: '2',
						ov_var4: '2',
						ov_var5: '2',
					})
					.then(res => {
						console.log("返回的res:" + JSON.stringify(res))
						that.$u.toast(res.msg);
						if (res.success) {

							let data = res.data
							// console.log("返回的data:" + JSON.stringify(data))
							console.log("返回的res.msg:" + res.msg)
							//补充text
							// this.actionSheetList = data.map(v => {
							// 	this.$set(v, 'text', v
							// 		.STORAGE_NAME) // https://vuejs.org/v2/guide/reactivity.html
							// 	return v
							// })
							// this.list = data
							// this.mxList = data
							// // 刷新明细数据展示
							// this.myMxShow()

							// // 默认选择一个明细
							// this.goTo(0)
							//成功后 下架数量归为1
							this.submitSuccess()
							if (paramReturn == "returnSearch") {
								//回到明细列表
								this.current = 0
							}
							//直接点击第一个
							// this.goTo(0,0)
							// this.getNextMx()
						}

					});
			},

			submitSuccess() {
				this.searchForm.location=''
				this.oneMx={}
			},
			navTo(url) {
				uni.navigateTo({
					url: url
				});
			},
			// 根据货位进行搜索
			getLocationMxList() {
				// 1、IV\_STORAGEID 仓库可以传%
				// 2、IV\_YEZ\_ID 业主id 可以传%
				// 3、IV\_USER\_ID 用户id,
				// 4、IV\_LOCATION 货位信息（货位信息，可以传%）
				// 5、IV\_GDTJ 商品信息（gdseq,69码，助记码）
				const STORAGE_ID = uni.getStorageSync('STORAGE_ID')
				const yez_id = this.searchForm.yez_id ? this.searchForm.yez_id : "%"
				const USER_ID = uni.getStorageSync('USER_ID')
				const location = this.searchForm.location ? this.searchForm.location : "%"
				const goodsMessage = this.searchForm.goodsMessage ? this.searchForm.goodsMessage : "%"

				if(this.searchForm.location){

				}else{
					this.$u.toast("请填写或扫描货位后再尝试查询")
					return ;
				}
				let param = STORAGE_ID + "," + yez_id + "," + USER_ID + ","
				+ location + ","+ goodsMessage ;

				console.log("iv_parm:" + param)
				let that = this
				this.$u.api.general({
						iv_code: "GETSTOCKPC",
						iv_parm: param
					})
					.then(res => {
						console.log("返回的res:" + JSON.stringify(res))
						if (res.success) {
							let data = res.data
							console.log("返回的data:" + JSON.stringify(data))
							//补充text
							// this.mxList = data
							if(data.length<1){
								this.$u.toast("暂无数据")
							}else{
								this.oneMx = data[0]
							}
							
							// 末尾显示
							// this.status = 'nomore';
						} else {
							this.dialogData={
								title:'货位查询',
								msgType: 'warn',
								errContent: res.msg,
								confirmText:'重试',
								// 如果选右边的执行的返回方法
								functionName:'getLocationMxList',
								cancelText:'关闭',
							}
							this.errDialogShow()
						}
					});
			},
			getOutTpbarList() {
				// 1、IV\_STAFF 用户id
				// 2、IV\_GZTID 工作站
				// 3、IV\_YEW\_TYPE业务类型2：出库
				// const STORAGE_ID = uni.getStorageSync('STORAGE_ID')
				// // const USER_GH = uni.getStorageSync('USER_GH')
				// const yez_id = this.form.huoz_id ? this.form.huoz_id : "%"
				const USER_ID = uni.getStorageSync('USER_ID')
				const GZTID = this.GZTID ? this.GZTID : "%"
				const yew_type = '2'
				let param = USER_ID + "," + GZTID + "," + yew_type;
				console.log("iv_parm:" + param)
				let that = this
				this.$u.api.general({
						iv_code: "PDAOUTTPBAR",
						iv_parm: param
					})
					.then(res => {
						// console.log("返回的res:" + JSON.stringify(res))
						let data = res.data
						// console.log("返回的data:" + JSON.stringify(data))
						if (res.success) {
							//补充text
							this.mxList = data
							// .map(v => {
							// 	this.$set(v, 'over', false) // https://vuejs.org/v2/guide/reactivity.html
							// 	this.$set(v, 'index', 0)
							// 	this.$set(v, 'total', data.length)
							// 	return v
							// })
							// this.list = data
							// this.mxList = data
							// 刷新明细数据展示
							// this.myMxShow()

							// 默认选择一个明细
							// this.goTo(0,0)
							// 末尾显示
							this.status = 'nomore';


						} else {
							this.$u.toast(res.msg);
						}
					});
			},

			blurFunction() {
				console.log("失去了焦点")
				this.myMxShow()
			},
			changeProductDate(e) {
				console.log("选择的日期:" + JSON.stringify(e))
				this.oneMx.PRODUCTDATE = e.result
				this.myMxShow()
			},
			changeEFFDATE(e) {
				this.oneMx.EFFDATE = e.result
				this.myMxShow()
			},
			changeGzt(index) {
				// 表层文字
				this.gztNowLabel = this.gztList[index].text;
				uni.setStorageSync('gztNowLabel', this.gztNowLabel)

				// id
				const GZTID = this.gztList[index].GZTID == "%" ? '' : this.gztList[index].GZTID;
				if (GZTID) {
					this.GZTID = GZTID
					uni.setStorageSync('IN_GZTID', GZTID)

				} else {
					this.GZTID = ''
					uni.removeStorageSync('IN_GZTID')
				}
				console.log("缓存中的入库工作站IN_GZTID:" + uni.getStorageSync('IN_GZTID'))

			},
			changeKuf(index) {
				// 表层文字
				// this.gztNowLabel = this.gztList[index].text;
				// uni.setStorageSync('gztNowLabel', this.gztNowLabel)

				// id
				const KUF_NO = this.kufList[index].KUF_NO == "%" ? '' : this.kufList[index].KUF_NO;
				console.log('选中的库房号:' + KUF_NO)
				if (KUF_NO) {
					this.kuf = KUF_NO
					uni.setStorageSync('kuf', KUF_NO)

				} else {
					this.kuf = ''
					uni.removeStorageSync('kuf')
				}
				console.log("缓存中的库房kuf:" + uni.getStorageSync('kuf'))

			},
			getGzt(loginType) {
				const user_id = uni.getStorageSync('USER_ID')
				const STORAGE_ID = uni.getStorageSync('STORAGE_ID')
				const kuf = "%"
				const gztType = "1"
				const gztId = "%"
				let param = user_id + "," + STORAGE_ID + "," + kuf + "," + gztType + "," + gztId;
				console.log(param)
				this.$u.api.general({
						iv_code: "GETGZTINFO",
						iv_parm: param
					})
					.then(res => {
						// console.log("返回的res:" + JSON.stringify(res))
						let data = res.data
						console.log("getGzt返回的data:" + JSON.stringify(data))
						if (res.success) {
							//补充text
							this.gztList = data.map(v => {
								this.$set(v, 'text', v
									.GZTNAME + "(" + v.GZTID + ")"
								) // https://vuejs.org/v2/guide/reactivity.html
								return v
							})
							//{
							// 	"WORKLOAD":"4",
							// "CENG":"1",
							// "GZT_TYPE":"1",
							// "ISZCQFP":"N",
							// "STORAGEID":"SU3",
							// "WORKSTATION_TYPE":"0",
							// "LETDOWNFLAG":"1",
							// "GZTID":"GZT000002",
							// "GZTNAME":"工作站一号",
							// "KUF_NO":"LHK"
							// }
							// 增加一条特殊的测试数据
							this.gztList.push({
								"text": "DHJ01",
								"WORKLOAD": "4",
								"CENG": "1",
								"GZT_TYPE": "1",
								"ISZCQFP": "N",
								"STORAGEID": "SU3",
								"WORKSTATION_TYPE": "0",
								"LETDOWNFLAG": "1",
								"GZTID": "DHJ01",
								"GZTNAME": "DHJ01测试工作站",
								"KUF_NO": "LHK"
							})
						} else {
							this.$u.toast(res.msg);
						}
					});
			},
			getKuf(loginType) {
				const USER_ID = uni.getStorageSync('USER_ID')
				const KUB = '%'
				const KUF_NO = "%"
				const GET_TYPE = "2"
				let param = USER_ID + "," + KUB + "," + KUF_NO + "," + GET_TYPE;
				console.log(param)
				this.$u.api.general({
						iv_code: "GETKUFQUYNO",
						iv_parm: param
					})
					.then(res => {
						// console.log("返回的res:" + JSON.stringify(res))
						let data = res.data
						console.log("kuf返回的data:" + JSON.stringify(data))
						if (res.success) {
							//补充text
							this.kufList = data.map(v => {
								this.$set(v, 'text', v
									.KUF_NO
									// +"("+v.GZTID+")"
								) // https://vuejs.org/v2/guide/reactivity.html
								return v
							})
						} else {
							this.$u.toast(res.msg);
						}
					});
			},
		}

	}
</script>
<style lang="scss" scoped>
	@import '../../common/index.scss';
	@import '../../common/base-change.scss';
</style>
